﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using EPlanet.Web.UI.WebControls;
using System.Web.UI;

namespace CommonModule
{
    public class DatePickerHelper
    {

        public static void SetDateAttr(DatePicker DatePicker1)
        {
            //设置一系列的属性
            DatePicker1.ImagePath = HttpContext.Current.Request.ApplicationPath + "/Images/DatePicker/";
            DatePicker1.DispalyLanguage = GetLanguage();
        }

        private static EPlanet.Web.UI.WebControls.DatePicker.Language GetLanguage()
        {
            switch (System.Threading.Thread.CurrentThread.CurrentCulture.Name.ToUpper())
            {
                case "ZH-CN":
                    return EPlanet.Web.UI.WebControls.DatePicker.Language.CN;
                case "EN-US":
                    return EPlanet.Web.UI.WebControls.DatePicker.Language.EN;
                case "RU-RU":
                    return EPlanet.Web.UI.WebControls.DatePicker.Language.RU;
                default:
                    return EPlanet.Web.UI.WebControls.DatePicker.Language.RU;
            }
        }

        public static void RegisterDatePickerScript(Page page)
        {
            string script = "<script language=JavaScript src=\"" + System.Web.HttpContext.Current.Request.ApplicationPath + "/Javascript/DatePicker.js\" charset=\"gb2312\"></script>";
            if (page != null)
            {
                if (!page.ClientScript.IsClientScriptBlockRegistered("DatePicker"))
                    page.ClientScript.RegisterStartupScript(page.GetType(), "DatePicker", script);
            };
        }
    }
}
